import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '学/工号',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '部门',
    align:"center",
    dataIndex: 'departmentId_dictText'
   },
   {
    title: '工作日期',
    align:"center",
    dataIndex: 'workDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '考勤规则',
    align:"center",
    dataIndex: 'timePeriodIdDetail'
   },
 {
    title: '上班刷卡时间',
    align:"center",
    dataIndex: 'onDutyTime'
   },
   {
    title: '下班刷卡时间',
    align:"center",
    dataIndex: 'offDutyTime'
   },
   {
    title: '已工作时长',
    align:"center",
    dataIndex: 'workMins'
   },
   {
    title: '迟到时长',
    align:"center",
    dataIndex: 'belateMins'
   },
   {
    title: '请假时长',
    align:"center",
    dataIndex: 'lateMins'
   },
   {
    title: '早退时长',
    align:"center",
    dataIndex: 'earlyMins'
   },
   {
    title: '旷工时长',
    align:"center",
    dataIndex: 'absentMins'
   },
  {
    title: '缺卡次数',
    align:"center",
    dataIndex: 'lessCard'
  },
   {
    title: '平时加班时长',
    align:"center",
    dataIndex: 'overMins'
   },
   {
    title: '周末加班时长',
    align:"center",
    dataIndex: 'weOverMins'
   },
   {
    title: '节假日加班时长',
    align:"center",
    dataIndex: 'holidayOverMins'
   },
   {
    title: '出差时长',
    align:"center",
    dataIndex: 'businessMins'
   },
   {
    title: '调休时长',
    align:"center",
    dataIndex: 'clMins'
   },
   {
    title: '是否休息日',
    align:"center",
    dataIndex: 'ifRestDay',
    customRender:({text}) =>{
      return !text?"":(text=='0'?'否':'是')
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
      label: "工作日",
      field: "workDate",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      //colProps: {span: 6},
  },
  {
      label: "学号",
      field: 'code',
      component: 'Input',
      //colProps: {span: 6},
  },
  {
      label: "姓名",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
  },
  {
      label: "部门",
      field: 'departmentId',
      component: 'JSelectDept',
      componentProps:{
            checkable:false,
            multiple:false,
     }
      //colProps: {span: 6},
  },
	{
      label: "是否休息日",
      field: 'ifRestDay',
      component: 'JDictSelectTag',
      componentProps:{
        options: [
          { label: '否', value: '0' },
          { label: '是', value: '1' },
        ],
      },
      //colProps: {span: 6},
 	}
];
//表单数据
export const formSchema: FormSchema[] = [
  {
      label: "学号",
      field: 'code',
      component: 'Input',
      //colProps: {span: 6},
  },
  {
      label: "姓名",
      field: 'name',
      component: 'JInput',
      //colProps: {span: 6},
  },
  {
      label: "部门",
      field: 'departmentId',
      component: 'JSelectDept'
      //colProps: {span: 6},
  },
  {
    label: '工作日期',
    field: 'workDate',
    component: 'DatePicker',
  },
  {
    label: '考勤规则',
    field: 'attRuleName',
    component: 'InputNumber',
  },
  {
    label: '上班刷卡时间',
    field: 'onDutyTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '下班刷卡时间',
    field: 'offDutyTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '已工作时长',
    field: 'workMins',
    component: 'InputNumber',
  },
  {
    label: '请假时长',
    field: 'lateMins',
    component: 'InputNumber',
  },
  {
    label: '早退时长',
    field: 'earlyMins',
    component: 'InputNumber',
  },
  {
    label: '旷工时长',
    field: 'absentMins',
    component: 'InputNumber',
  },
  {
    label: '平时加班时长',
    field: 'overMins',
    component: 'InputNumber',
  },
  {
    label: '周末加班时长',
    field: 'weOverMins',
    component: 'InputNumber',
  },
  {
    label: '节假日加班时长',
    field: 'holidayOverMins',
    component: 'InputNumber',
  },
  {
    label: '出差时长',
    field: 'businessMins',
    component: 'InputNumber',
  },
  {
    label: '调休时长',
    field: 'clMins',
    component: 'InputNumber',
  },
  {
    label: '是否休息日',
    field: 'ifRestDay',
    component: 'JDictSelectTag',
    componentProps:{
       options: [
         { label: '否', value: '0' },
         { label: '是', value: '1' },
       ],
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  personId: {title: '人员id',order: 0,view: 'text', type: 'string',},
  workDate: {title: '工作日期',order: 1,view: 'date', type: 'string',},
  attRuleId: {title: '考勤规则ID',order: 2,view: 'number', type: 'number',},
  onDutyTime: {title: '上班刷卡时间',order: 3,view: 'datetime', type: 'string',},
  offDutyTime: {title: '下班刷卡时间',order: 4,view: 'datetime', type: 'string',},
  workMins: {title: '已工作时长',order: 5,view: 'number', type: 'number',},
  lateMins: {title: '请假时长',order: 6,view: 'number', type: 'number',},
  earlyMins: {title: '早退时长',order: 7,view: 'number', type: 'number',},
  absentMins: {title: '旷工时长',order: 8,view: 'number', type: 'number',},
  overMins: {title: '平时加班时长',order: 9,view: 'number', type: 'number',},
  weOverMins: {title: '周末加班时长',order: 10,view: 'number', type: 'number',},
  holidayOverMins: {title: '节假日加班时长',order: 11,view: 'number', type: 'number',},
  businessMins: {title: '出差时长',order: 12,view: 'number', type: 'number',},
  clMins: {title: '调休时长',order: 13,view: 'number', type: 'number',},
  ifRestDay: {title: '是否休息日',order: 14,view: 'list', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}

export const resultColumns: BasicColumn[] = [
  {
   title: '学/工号',
   align:"center",
   dataIndex: 'code'
  },
  {
   title: '姓名',
   align:"center",
   dataIndex: 'name'
  },
  {
   title: '部门',
   align:"center",
   dataIndex: 'departmentId_dictText'
  },
  // {
  //  title: '考勤规则',
  //  align:"center",
  //  dataIndex: 'attRuleName'
  // },
  // {
  //  title: '上班刷卡时间',
  //  align:"center",
  //  dataIndex: 'onDutyTime'
  // },
  // {
  //  title: '下班刷卡时间',
  //  align:"center",
  //  dataIndex: 'offDutyTime'
  // },
  {
   title: '已工作时长',
   align:"center",
   dataIndex: 'workMins'
  },
  {
   title: '迟到时长',
   align:"center",
   dataIndex: 'belateMins'
  },
  {
   title: '请假时长',
   align:"center",
   dataIndex: 'lateMins'
  },
  {
   title: '早退时长',
   align:"center",
   dataIndex: 'earlyMins'
  },
  {
   title: '旷工时长',
   align:"center",
   dataIndex: 'absentMins'
  },
  {
    title: '缺卡',
    align:"center",
    dataIndex: 'lessCard'
  },
  {
   title: '平时加班时长',
   align:"center",
   dataIndex: 'overMins'
  },
  {
   title: '周末加班时长',
   align:"center",
   dataIndex: 'weOverMins'
  },
  {
   title: '节假日加班时长',
   align:"center",
   dataIndex: 'holidayOverMins'
  },
  {
   title: '出差时长',
   align:"center",
   dataIndex: 'businessMins'
  },
  {
   title: '调休时长',
   align:"center",
   dataIndex: 'clMins'
  },
  {
   title: '是否休息日',
   align:"center",
   dataIndex: 'ifRestDay',
   customRender:({text}) =>{
     return !text?"":(text=='0'?'否':'是')
   },
  },
];
